
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>记住密码功能</title>
</head>
<body>
<%
    //获取Cookie
    Cookie[] cookies=request.getCookies();
    if (cookies!=null){
        for (Cookie cookie:cookies){
            //判断当前循环到的Cookies是否是需要的
            if (cookie.getName().equals("username")){
                pageContext.setAttribute("username",cookie.getValue());
            }
            if (cookie.getName().equals("password")){
                pageContext.setAttribute("password",cookie.getValue());
            }
        }
    }
%>
<form action="loginCookieServlet" method="post">
    账号:<input type="text" name="username" value="${username}"><br>
    密码:<input type="password" name="password" value="${password}"><br>
    <input type="checkbox" name="rem" value="ok" ${empty username?'':'checked'}>记住密码<br>
    <input type="submit" value="登录">
</form>
</body>
</html>
